package com.adie.controller;

import com.adie.mapper.UserMapper;
import com.adie.pojo.OldMan;
import com.adie.pojo.Volunteer;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendOldToVolunteer {
    @Autowired
    private UserMapper userMapper;
    @PostMapping("/sendOpenid_volunteer")
    public String getOldMessage(@RequestBody JSONObject jsonObject){
        String openid_volunteer=jsonObject.get("openid_volunteer").toString();
        Volunteer volunteer = userMapper.queryVolunteer(openid_volunteer);
        System.out.println(openid_volunteer);
        if(volunteer==null)return "您暂无分配的老人";
        else {
            System.out.println(volunteer);
            String openid_old = volunteer.getOpenid_old();
            OldMan oldMan = userMapper.queryOldMan(openid_old);
            return oldMan.getArticle();
        }
    }
}
